home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / qex / qexsndcd / cwmon.dsp < prev    next >
Text File  |  1994-07-06  |  9KB  |  276 lines

  1. { --------------------------------------------------------------------- }
  2. {      Super Simple DSP bootstrap monitor for testing the CW filter     }
  3. {      Demo software accompanying the QEX August 1994 article:        }
  4. {      "Programming a DSP PC Sound Card for Amateur Radio"              }
  5. {                  (c) Johan Forrer, KC7WW                }
  6. {             26553 Priceview Drive                              }
  7. {                    Monroe, OR 97456                    }
  8. { --------------------------------------------------------------------- }
  9. {  Acknowlegements to:                             }
  10. {  Joe Ballantyne, Echo Speech Corporation                              }
  11. {  DSP Applications Group, Analog Devices                               }
  12. { --------------------------------------------------------------------- }
  13. {                                    }
  14. {            Compilation instructions:                                  }  
  15. {                 >spasm21 cwmon.dsp                                  }
  16. {                 >cload   cwmon                        }
  17. {                                    }
  18. { --------------------------------------------------------------------- }
  19.  
  20.                 { Monitor version number                }
  21.                                 { returned when monitor is initialized  }
  22. .CONST version = 0x0100;        { msb byte represents integer value     }
  23.                                 { lsb byte represents a decimal value   }
  24.                                 { from .01 to .99                       }
  25.  
  26. { --------------------------------------------------------------------- }
  27. {    List of implemented call and answer functions                }
  28. { --------------------------------------------------------------------- }
  29. {    CODE     Function                        }
  30. {       --------------------                        }
  31. {    0x00b0 - Start timer                        }
  32. {    0x00b1 - End timer                        }
  33. {    0x00b4 - Start application                        }
  34. {    0x00b5 - End   application                    }
  35. {    0x00d0 - Read  Dm location                    }
  36. {    0x00d1 - Write Dm location                    }
  37. {    0x00d2 - Read  Pm location                    }
  38. {    0x00d3 - Write Pm location                    }
  39. {    0x00d4 - Send back "PSA-MON" string                }
  40. { --------------------------------------------------------------------- }
  41.  
  42. {             The folling are a number of useful addresses        }
  43.  
  44. .const PSS_data_reg    =0x3000;
  45. .const PSS_control_reg    =0x3008;
  46. .const PSS_status_reg    =0x3008;
  47. .const PSS_dma_reg    =0x3010;
  48. .const ram_bank_reg    =0x3018;
  49. .const ext_mem_latch    =0x3020;
  50.  
  51. .const addr_1848    =0x3440;
  52. .const data_1848    =0x3448;
  53. .const stat_1848    =0x3450;
  54. .const pio_1848        =0x3458;
  55. .const IRQ_status    =0x31C0;
  56. .const dmal_1848    =0x3060;
  57. .const dmar_1848    =0x3068;
  58. .const enable_1848    =0x3070;
  59.  
  60. .const system_control    =0x3FFF;
  61. .const wait_state_ctl    =0x3FFE;
  62. .const timer_period    =0x3FFD;
  63. .const timer_counter    =0x3FFC;
  64. .const timer_prescale    =0x3FFB;
  65.  
  66.  
  67. { Note: delay lines use circular addressing                                 }
  68. {         9- 16 requires a " 16=0x0010" boundary                            }
  69. { length 17- 32 requires a " 32=0x0020" boundary                            }
  70. {        33- 64 requires a " 64=0x0040" boundary                            }
  71. {        65-128 requires a "128=0x0080" boundary                            }
  72. {       129-256 requires a "256=0x0100" boundary                            }
  73.  
  74. { Here we define the start address of our DSP application that                 }
  75. { incidentally are embedded in the AD1848 sound port ISR                    } 
  76. .const sound_port    =0x0100;    { ISR is at 0100            }
  77.  
  78. { Define space for the FIR bandpass filter delay line                }
  79. .const BPFI        =0x3800;    { 3800 ->  Input bandpass         }
  80.  
  81. {--------------------INTERRUPT VECTORS--------------------------------------}
  82.     jump main_; nop; nop; nop;      { 0000 restart interrupt}
  83.     jump sound_port; nop; nop; nop;    { 0004 IRQ2 interrupt}
  84.     rti; nop; nop; nop;             { 0008 SPORT0 tx interrupt}
  85.     rti; nop; nop; nop;             { 000C SPORT0 rx interrupt}
  86.     rti; nop; nop; nop;             { 0010 IRQ1 or SPORT1 tx}
  87.     rti; nop; nop; nop;             { 0014 pc_irq_vec }
  88.     jump timer_int;nop;nop;nop;    { 0018 Timer interrupt }
  89. { ************************************************************************** }
  90. main_:
  91.     ax0 = dm(PSS_data_reg);     { dummy read to clear out last boot byte}
  92.     ax1 = version;              { send version number to PC}
  93.     call put_word_;
  94.  
  95.     ax0 = 0x0007;         { no nesting of interrupts }
  96.     ICNTL=ax0;        { all interupts EDGE sensitive }
  97.  
  98.     ax0 = 0xFFFF;        { for max length Timer period }
  99.     dm(timer_period) = ax0;
  100.     ax0 = 0x00FF;
  101.     dm(timer_prescale) = ax0; { Max Timer prescale}
  102.  
  103.     ax0 = 0x0011;         { enable timer and IRQ2 interrupts - for DMA}         
  104.     IMASK = ax0;
  105.  
  106.     l0=0;l1=0;l2=0;l3=0;    { all length (modulo) registers }
  107.     l4=0;l5=0;l6=0;l7=0;    { should be set to 0   }
  108.  
  109.     m0=0;m1=1;m2=0;m3=-1;   { modify registers set ( DAG1 set) }
  110.     m4=0;m5=1;m6=0;m7=-1;   { to various constants ( DAG2 set) }
  111.  
  112.     ax0=0x2000;
  113.     dm(wait_state_ctl)=ax0; { set 2 wait states- Sound port }
  114.                 { zero wait states for everything else }
  115.     ax0=dm(system_control); { read the system control register}
  116.     ay0=0xfff8;
  117.     ar=ax0 and ay0;         { make program mem 0 wait state}
  118.     dm(system_control)=ar;
  119.  
  120.     ax0 = 0x2000;        { set SPWE (bit 13) in IRQ enable register }
  121.     dm(IRQ_status)=ax0;    { to allow DMA interrupts }
  122.  
  123. {---------------------------------------------------------------------------}
  124. { Start looking for a call and answer command                               }
  125. loop_:                
  126.     call get_word_;
  127.  
  128.     ay0=0x00d0;        { Dm read  }
  129.     ar=ax0 xor ay0;
  130.     if eq jump data_read_;
  131.  
  132.     ay0=0x00d1;        { Dm write }
  133.     ar=ax0 xor ay0;
  134.     if eq jump data_write_;
  135.  
  136.     ay0=0x00d2;        { Pm read  }
  137.     ar=ax0 xor ay0;        
  138.     if eq jump program_read_;
  139.  
  140.     ay0=0x00d3;        { Pm write  }
  141.     ar=ax0 xor ay0;
  142.     if eq jump program_write_;
  143.  
  144.     ay0=0x00d4;        { Send back PSA-MON string }
  145.     ar=ax0 xor ay0;
  146.     if eq jump prog_id_write_; 
  147.  
  148.     ay0=0x00b4;        { Start application }
  149.     ar=ax0 xor ay0;
  150.     if eq jump start_app; 
  151.  
  152.     ay0=0x00b5;        { End application }
  153.     ar=ax0 xor ay0;
  154.     if eq jump end_app; 
  155.  
  156.     ay0=0x00b0;        { Start timer }
  157.     ar=ax0 xor ay0;
  158.     if eq jump start_timer; 
  159.  
  160.     ay0=0x00b1;        { Stop timer }
  161.     ar=ax0 xor ay0;
  162.     if eq jump stop_timer; 
  163.  
  164.     jump loop_;
  165.  
  166. {---------------------------------------------------------------------------}
  167. { Timer ISR                                                                 }
  168. { Assert PC interrupt                                                       }
  169. timer_int:
  170.     ena sec_reg;
  171.     ax0=0x1000;
  172.     dm(PSS_control_reg)=ax0;
  173.     dis sec_reg;
  174.     rti;
  175.  
  176. {---------------------------------------------------------------------------}
  177. { Call and Answer functions                                                 }
  178. data_read_:
  179.     call get_word_;
  180.     i6 = ax0;
  181.     ax1 = dm(i6,m6);          { m6=0 }
  182.     call put_word_;
  183.     jump loop_;
  184.  
  185. data_write_:
  186.     call get_word_;
  187.     i6 = ax0;
  188.     call get_word_;
  189.     dm(i6,m6)=ax0;
  190.     jump loop_;
  191.  
  192. program_read_:
  193.     call get_word_;
  194.     i6 = ax0;
  195.     ax1 = pm(i6,m6);
  196.     call put_word_;
  197.     ax1 = px;
  198.     call put_word_;
  199.     jump loop_;
  200.  
  201. program_write_:
  202.     call get_word_;
  203.     i6 = ax0;
  204.     call get_word_;
  205.     px = ax0;
  206.     call get_word_;
  207.     pm(i6,m6)=ax0;
  208.     jump loop_;
  209.  
  210. prog_id_write_:
  211.     ax1=0x0050;        { P }
  212.     call put_word_;
  213.     ax1=0x0053;        { S }
  214.     call put_word_;
  215.     ax1=0x0041;        { A }
  216.     call put_word_;
  217.     ax1=0x002D;             { - }
  218.     call put_word_;
  219.     ax1=0x004D;             { M }
  220.     call put_word_;
  221.     ax1=0x004F;             { O }
  222.     call put_word_;
  223.     ax1=0x004E;             { N }
  224.     call put_word_;
  225.     ax1=0x0000;
  226.     call put_word_;
  227.     jump loop_;
  228.  
  229. get_word_:
  230.     ay0=0x4000;
  231.     ax0=dm(PSS_status_reg);
  232. gwloop:
  233.     ar=ax0 and ay0;
  234.     ax0=dm(PSS_status_reg);
  235.     if eq jump gwloop;
  236.     ax0=dm(PSS_data_reg);
  237.     rts;
  238.  
  239. put_word_:
  240.     ax0=dm(PSS_status_reg);
  241.     ay0=0x8000;
  242.     ar=ax0 and ay0;
  243.     if eq jump put_word_;
  244.     dm(PSS_data_reg) = ax1;
  245.     rts;
  246.  
  247. { Stop/Start TIMER -------------------------------------------------------- }
  248. start_timer:    
  249.     ENA TIMER;
  250.     jump    loop_;
  251. stop_timer:
  252.     DIS TIMER;
  253.     jump    loop_;
  254.  
  255. { Start/Stop application   ------------------------------------------------ }
  256. start_app:
  257.     ax0=0xFFFF;
  258.     dm(enable_1848)=ax0;    { Let DSP access 1848 }
  259.  
  260.     i1=BPFI;        { Pointers and lengths }
  261.     l1=127;                
  262.  
  263.     ax0 = 0x0021;         { enable IRQ2 interrupts - for DMA}         
  264.     IMASK = ax0;        { enable TIMER interrupts too }
  265.  
  266.     jump loop_;
  267.     
  268. end_app:
  269.     ax0 = 0x0000;         { disable IRQ2 interrupts - for DMA}         
  270.     IMASK = ax0;
  271.     ax0=0x0000;        { get ready to return to the PC }
  272.     dm(enable_1848)=ax0;    { Now let PC access 1848 }
  273.  
  274.     jump loop_;
  275. {---------------------------------------------------------------------------}
  276.